package com.junmeng.demo.libtopview

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.junmeng.demo.libtopview.SimpleDialogViewFactory.Companion.VIEW_TYPE_SIMPLE_DIALOG
import com.junmeng.demo.libtopview.databinding.LayoutActivityDialogBinding
import com.junmeng.demo.libtopview.databinding.LayoutActivityFloatingBinding
import com.junmeng.lib.ui.topview.core.WindowTopViewManager

class DialogActivity : AppCompatActivity() {
    private lateinit var mBinding:LayoutActivityDialogBinding
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.layout_activity_dialog)

        mBinding = LayoutActivityDialogBinding.inflate(layoutInflater)
        setContentView(mBinding.root)

        mBinding.btnRegister.setOnClickListener {
            WindowTopViewManager.registerViewFactory(SimpleDialogViewFactory())
        }
        mBinding.btnUnregister.setOnClickListener {
            WindowTopViewManager.unregisterViewFactory(VIEW_TYPE_SIMPLE_DIALOG)
        }
        mBinding.btnApply.setOnClickListener {
            WindowTopViewManager.applyViewFactory(VIEW_TYPE_SIMPLE_DIALOG)
        }
        mBinding.btnUnapply.setOnClickListener {
            WindowTopViewManager.unapplyViewFactory(VIEW_TYPE_SIMPLE_DIALOG)
        }
        mBinding.btnUnapplyOnlyCurrent.setOnClickListener {
            WindowTopViewManager.unapplyViewFactoryOnlyCurrent(VIEW_TYPE_SIMPLE_DIALOG)
        }

        mBinding.btnEnterMainActivity.setOnClickListener {
            startActivity(Intent(this, MainActivity::class.java))
        }

        mBinding.btnEnterFloatingActivity.setOnClickListener {
            startActivity(Intent(this, FloatingActivity::class.java))
        }
    }
}